home *** CD-ROM | disk | FTP | other *** search
- /*
- $VER: CleanSystem.thor 1.0 (11.9.98)
- © Neil Bothwick
- */
-
- /* Removes "orphaned" files from the system directory, */
- /* left over from previously deleted conferences */
- /* Copy this script to Thor/rexx and run it from Thor's arexx menu. */
- /* It will clean orphaned files from the current system */
-
- /*;;; Initialise */
- options results
- FoundCount = 0
- DelCount = 0
- ;;;
- /* ;;;Needs THOR and bbsread.library functions */
- thorport = address()
- if left(thorport,5) ~= 'THOR.' then do
- say 'CleanSystem.thor must be run from within Thor.'
- exit
- end
-
- if ~show('p', 'BBSREAD') then do
- address command
- 'run >nil: `GetEnv THOR/THORPath`bin/LoadBBSRead'
- 'WaitForPort BBSREAD'
- end
- ;;;
- /* ;;;Get current system name,conference list and data directory */
- address(thorport)
- drop TMP.
- 'CURRENTSYSTEM stem TMP'
- System = TMP.BBSNAME
- address 'BBSREAD'
- drop TMP. CONFLIST.
- 'GETCONFLIST "'System'" CONFLIST'
- 'GETBBSDATA "'system'" stem TMP'
- SystemDir = TMP.BBSPATH
- call pragma('D',SystemDir)
- ;;;
- /* ;;; Build file list and compare each entry with the conference list */
- address command 'list' SystemDir 'pat MsgData#? files lformat "%N %C" to T:CleanSystem.tmp'
- if ~open(FileList,'T:CleanSystem.tmp','R') then call ExitMsg('Failed to open temporary file')
- address(thorport)
- do until eof(FileList)
- line = readln(FileList)
- if line = '' then iterate
- File = subword(line,1,1)
- FileNo = substr(File,8)
- Conf = subword(line,2)
- if Conf = '' then call ExitMsg('File found with no comment')
- do i = 1 to CONFLIST.COUNT
- if upper(CONFLIST.i) == upper(Conf) then leave
- end
- if i > CONFLIST.COUNT then do
- FoundCount = FoundCount + 1
- 'REQUESTNOTIFY TEXT "File 'File' matches non-existent conference:\n'Conf'" BT "Delete|Leave"'
- if result = 1 then do
- DelCount = DelCount + 1
- address command 'delete >NIL:' File 'MsgHash'FileNo 'MsgHead'FileNo 'MsgMarked'FileNo 'MsgText'FileNo
- end
- end
- end
- call close(FileList)
- address command 'Delete >NIL: T:CleanSystem.tmp'
- If FoundCount = 0 then ReportText = 'No orphaned files found'
- else ReportText = 'Found orphaned files for' FoundCount 'deleted conferences\nDeleted 'DelCount
- 'REQUESTNOTIFY TEXT "'ReportText'" BT "OK"'
- if RC > 0 then call ExitMsg(THOR.LASTERROR)
- ;;;
- exit
-
- /* ;;; Exit with a message */
- ExitMsg:
- parse arg ErrTxt
- address(thorport)
- 'REQUESTNOTIFY "'ErrTxt'" "Abort"'
- exit
- ;;;
-